package com.gao.flying.example;

import java.time.LocalDateTime;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javax.jms.JMSException;

import com.gao.flying.mq.JmsClient;

public class DemoProducer {

	private ScheduledExecutorService service = Executors.newScheduledThreadPool(8);

	public void start() {
		service.scheduleWithFixedDelay(() -> {
            try {
                JmsClient.sendMessage("test1", LocalDateTime.now().toString());
            } catch (JMSException e) {
                e.printStackTrace();
            }
        }, 1, 5, TimeUnit.SECONDS);
	}
	
	public static void main(String[] args) {
		
		DemoProducer producer = new DemoProducer();
		producer.start();
	}
}
